package com.lfsenior.email.serviceimp;

import com.lfsenior.email.entity.EmailEntity;
import com.lfsenior.email.service.ISendEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * Created by dlupan on 2018/9/14
 */
@Service
public class SendEmailService implements ISendEmailService {
    @Autowired
    private JavaMailSender mailSender;

    @Override
    public void sendSimpleEmail(EmailEntity emailEntity) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(emailEntity.getFrom());
        message.setTo(emailEntity.getTo());
        message.setSubject(emailEntity.getSubject());
        message.setText(emailEntity.getText());
        mailSender.send(message);
    }

}
